export const DownloadFile = (url, name) => {
    uni.downloadFile({
        url: url,//下载地址接口返回
        success: (data) => {
            if (data.statusCode === 200) {
                //文件保存到本地
                uni.saveFile({
                    tempFilePath: data.tempFilePath, //临时路径
                    success: function (res) {
                        uni.showToast({
                            icon: 'none',
                            mask: true,
                            title: 'The file has been saved：' + res.savedFilePath, //保存路径
                            duration: 3000,
                        });
                        setTimeout(() => {
                            //打开文档查看
                            uni.openDocument({
                                filePath: res.savedFilePath,
                                success: function (res) {
                                    // console.log('打开文档成功');
                                }
                            });
                        }, 3000)
                    }
                });
            }
        },
        fail: (err) => {
            console.log(err);
            uni.showToast({
                icon: 'none',
                mask: true,
                title: '失败请重新下载',
            });
        },
    });
}